Colliding Rects [migrated]

Posted by user73400 on Programmers See other posts from Programmers or by user73400
Published on 2012-11-23T00:41:25Z Indexed on 2012/11/23 5:09 UTC
Read the original article Hit count: 117

Filed under:

I have been working on this game, but I have a question when it comes to collision detection. Can I check for collision and have it return True:

example:

def collide(self, EnemyTank):
     tank_collision = pygame.sprite.collide_rect(self.rect, EnemyTank.rect)
     if tank_collision == True:
          return True

And then make it perform an action like this:

if player.collide == True:
     e_tank_x += 0

I am new to programming so please bear with me, I am trying as hard as I can and any comments or suggestions would also be very appreciated.

© Programmers or respective owner

Related posts about python